/*
 * Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum ingilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package cn.itenzo.common.validate;

import com.baidu.unbiz.fluentvalidator.Validator;
import com.baidu.unbiz.fluentvalidator.ValidatorContext;
import com.baidu.unbiz.fluentvalidator.ValidatorHandler;


/**
 * Created by ENZO on 2017/4/15.
 */

/**
 * url 校验, 中间存有 [://] 的格式
 */
public class UrlValidate extends ValidatorHandler<String> implements Validator<String> {


    @Override
    public boolean validate(ValidatorContext context, String s) {
        String regx = "[a-zA-z]+://[^\\s]*";

        if (null == s || s.length() <= 0 || !s.matches(regx)) {
            context.addErrorMsg(String.format("%s,网址有误",s));
            return false;
        }
        return true;

    }
}
